/*
*	File: CoreMesh.cpp
*	Date: 12/18/2011
*	Author: Ivan Gao
*	Desc:
*/
#include "CoreMesh.h"
#include "CoreSubMesh.h"
SCoreMesh::SCoreMesh ()
{

}

SCoreMesh::~SCoreMesh ()
{
	SCoreSubMeshVector::iterator itr = m_vecCoreSubMesh.begin();
	while (itr != m_vecCoreSubMesh.end ())
	{
		if (*itr)
		{	
			delete *itr;
		}
		++ itr;
	} // while
	m_vecCoreSubMesh.clear ();
}

int SCoreMesh::AddCoreSubMesh (SCoreSubMesh * pCoreSubMesh)
{
	int nSubMeshId = m_vecCoreSubMesh.size ();
	m_vecCoreSubMesh.push_back(pCoreSubMesh);
	return nSubMeshId;
} // AddCoreSubMesh

int SCoreMesh::GetCoreSubMeshCount() const
{
	return m_vecCoreSubMesh.size();
} // GetCoreSubMeshCount

bool SCoreMesh::RemoveCoreSubMesh(int nSubMeshId)
{
	if (nSubMeshId >= 0 && nSubMeshId < (int)m_vecCoreSubMesh.size ())
	{
		delete m_vecCoreSubMesh[nSubMeshId];
		m_vecCoreSubMesh[nSubMeshId] = NULL;
		return true;
	}
	return false;
} // RemoveCoreSubMesh

SCoreSubMesh * SCoreMesh::GetCoreSubMesh(int nSubMeshId)
{
	if (nSubMeshId >= 0 && nSubMeshId < (int)m_vecCoreSubMesh.size())
	{
		return m_vecCoreSubMesh[nSubMeshId];
	} // if
	return NULL;
} // GetCoreSubMesh

const SCoreSubMesh * SCoreMesh::GetCoreSubMesh (int nSubMeshId) const
{
	if (nSubMeshId >= 0 && nSubMeshId < (int)m_vecCoreSubMesh.size ())
	{
		return m_vecCoreSubMesh[nSubMeshId];
	} // if
	return NULL;
} // GetCoreSubMesh

SCoreSubMeshVector & SCoreMesh::GetCoreSubMeshVector () 
{
	return m_vecCoreSubMesh;
} // GetCoreSubMeshVector

const SCoreSubMeshVector & SCoreMesh::GetCoreSubMeshVector () const
{
	return m_vecCoreSubMesh;
} // GetCoreSubMeshVector

int SCoreMesh::AddAsMorphTarget(SCoreMesh * pCoreMesh, const char * pMorphMeshName)
{
	return 0;
} // AddAsMorphTarget

void SCoreMesh::Scale (float scale)
{
	SCoreSubMeshVector::iterator itr = m_vecCoreSubMesh.begin();
	while (itr != m_vecCoreSubMesh.end ())
	{
		if (*itr)
		{
			(*itr)->Scale ();
		} // if
	} // while
} // Scale

void SCoreMesh::SetFileName (const char * pFileName)
{
	m_strFileName = pFileName;
} // SetFileName

const string SCoreMesh::GetFileName (void) const
{
	return m_strFileName;
} // GetFileName

void SCoreMesh::SetName (const char * pName)
{
	m_strName = pName;
} // SetName

const string & SCoreMesh::GetName (void) const
{
	return m_strName;
} // GetName







